<template>
  <view class="my_box" :class="popupShow ? 'tl-show' : ''">
    <view class="top">
      <view class="myxx">
        <image v-if="userinfo.avatarImage" mode="widthFix" :src="userinfo.avatarImage" />
        <image v-if="!userinfo.avatarImage" mode="widthFix" src="http://cdn.jxsr.com/my_tx.png" />
        <view class="xx">
          <view class="name">
            {{ userinfo.nickName ? userinfo.nickName : 'Hi' }}
          </view>
          <view class="dh">
            {{ userinfo.phone ? userinfo.phone : '请登录' }}
          </view>
        </view>
      </view>
      <view class="mysj">
        <view class="title"> 交易数据 </view>
        <view class="ifys">
          <!-- <view @click="indent">
            <p class="p1">{{ orderQuantity ? orderQuantity : 0 }}</p>
            <p class="p2">订单</p>
          </view> -->
          <view @click="bill">
            <p class="p1">{{ userinfo.quota ? userinfo.quota : 0 }}</p>
            <p class="p2">信用金</p>
          </view>
        </view>
      </view>
    </view>
    <!-- <view class="operate">
      <view class="vis" @click="bill()">
        <image style="width: 23px; height: 22px" mode="widthFix" src="http://cdn.jxsr.com/my_zd.png" />
        <view style="-webkit-flex: 1; flex: 1">我的账单</view>
        <image style="width: 8px; height: 10px" mode="widthFix" src="http://cdn.jxsr.com/right.png" />
      </view>
    </view> -->
    <view class="operate">
      <!-- <view class="vis" @click="bill()">
        <image style="width: 23px; height: 22px" mode="widthFix" src="http://cdn.jxsr.com/my_zd.png" />
        <view style="-webkit-flex: 1; flex: 1">我的账单</view>
        <image style="width: 8px; height: 10px" mode="widthFix" src="http://cdn.jxsr.com/right.png" />
      </view> -->

      <view class="vis" @click="indent">
        <image style="width: 23px; height: 22px" mode="widthFix" src="../../static/a-065_waisong.png" />
        <view style="-webkit-flex: 1; flex: 1">订单</view>
        <image style="width: 8px; height: 10px" mode="widthFix" src="http://cdn.jxsr.com/right.png" />
      </view>

      <!-- <view class="vis" @click="install">
        <image style="width: 23px; height: 22px" mode="widthFix" src="http://cdn.jxsr.com/sz.png" />
        <view style="-webkit-flex: 1; flex: 1">设置</view>
        <image style="width: 8px; height: 10px" mode="widthFix" src="http://cdn.jxsr.com/right.png" />
      </view> -->

      <view class="vis" v-if="userinfo.nodeGrade == 1" @click="scanOrder">
        <image style="width: 23px; height: 22px" mode="widthFix" src="../../static/a-065_yinle-11.png" />
        <view style="-webkit-flex: 1; flex: 1">扫码核销</view>
        <image style="width: 8px; height: 10px" mode="widthFix" src="http://cdn.jxsr.com/right.png" />
      </view>
    </view>
  </view>
</template>

<script>
import useHttp from '@/utils/http.js';

export default {
  data() {
    return {
      orderQuantity: '0',
      userDpId: 0,
      // 身份数据
      identity: {},
      // 是否登录
      islogin: false,

      popupShow: false,
    };
  },
  props: {
    userinfo: {
      type: Object,
      default: null,
    },
  },
  mounted() {
    this.popupShow = false;
    if (uni.getStorageSync('token') && uni.getStorageSync('token') != '') {
      this.islogin = true;
      this.userDpId = uni.getStorageSync('appShopId');
      // this.orderFns()
    }
  },
  methods: {
    scanOrder() {
      uni.scanCode({
        onlyFromCamera: true,
        scanType: ['qrCode'],
        success: async ({ result, scanType, charSet, path }) => {
          console.log('result:', result);

          let orderId = JSON.parse(result).orderId;

          let res = await useHttp().get('/api/home/scanCode', { orderId });
          if (res.code == 200) {
            uni.showToast({
              title: res.msg,
              duration: 2000,
              icon: 'none',
            });
          }
        },
        fail: (error) => { },
      });
    },
    // 订单
    indent() {
      uni.navigateTo({
        url: 'indent/indent',
      });
    },
    // 账单
    bill() {
      uni.navigateTo({
        url: '/pages/my/bill/bill',
      });
    },
    // 设置
    install() {
      uni.navigateTo({
        url: 'install',
      });
    },

    // 遮罩层显示隐藏
    newProject() {
      this.popupShow = !this.popupShow;
    },
  },
};
</script>

<style scoped lang="scss">
.my_box {

  // position: relative;
  .top {
    width: 100%;
    height: 170px;
    padding-top: 30px;
    background: url('http://cdn.jxsr.com/my_fiche.png') no-repeat;
    background-size: 100% 100%;
    position: relative;

    .myxx {
      padding: 33px 20px;
      display: flex;

      image {
        width: 60px;
        height: 60px;
        border-radius: 40px;
      }

      .xx {
        width: 80%;
        padding: 0 0 0 10px;

        .name {
          font-size: 24px;
          font-family: PingFangSC-Semibold, PingFang SC;
          font-weight: 600;
          color: #ffffff;
          line-height: 40px;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          -o-text-overflow: ellipsis;
        }

        .dh {
          font-size: 15px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #ffffff;
          line-height: 20px;
        }
      }
    }

    .mysj {
      // width: 95%;
      height: 120px;
      margin: 0 10px;
      background: #ffffff;
      border-radius: 20px;

      .title {
        font-size: 20px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 600;
        color: $mainText;
        line-height: 45px;
        padding: 0 20px;
      }

      .ifys {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 0 20px;

        view {
          width: 50%;
          height: 70px;
          display: flex;
          flex-direction: column;
          justify-content: space-evenly;
          align-items: center;

          .p1 {
            font-size: 20px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 600;
            color: $primaryTextColor;
            line-height: 24px;
          }

          .p2 {
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 600;
            color: $text;
            line-height: 14px;
          }
        }
      }
    }
  }

  .topup {
    background: #ffffff;
    border-radius: 20px;
    margin: 85px 10px 0 10px;
    padding: 0 10px 0 10px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;

    .lef {
      display: flex;

      .txt {
        margin-left: 15px;
        display: flex;
        flex-direction: column;
        justify-content: space-evenly;

        view:nth-child(1) {
          font-size: 20px;
          font-family: PingFangSC-Semibold, PingFang SC;
          font-weight: 600;
          color: $mainText;
          line-height: 28px;
        }

        view:nth-child(2) {
          font-size: 15px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: $text;
          line-height: 21px;
        }
      }
    }

    .rig {
      width: 80px;
      height: 30px;
      border-radius: 15px;
      opacity: 0.6;
      border: 1px solid $primaryTextColor;
      font-size: 15px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: $primaryTextColor;
      line-height: 30px;
      text-align: center;
    }
  }

  .operate {
    background: #ffffff;
    border-radius: 20px;
    margin: 10px 10px 0 10px;
    padding: 0 10px 0 20px;

    margin-top: 200rpx;

    .vis {
      width: 100%;
      height: 50px;
      display: flex;
      align-items: center;

      view {
        margin-left: 10px;
        height: 100%;
        line-height: 50px;
        font-size: 18px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: $mainText;
      }
    }
  }

  .bots {
    border-radius: 20px;
    margin: 10px 10px 0 10px;
    padding: 10px 10px 10px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;

    image {
      width: 18px;
      height: 18px;
    }
  }

  .bots_mar {
    margin-bottom: 70px;
  }

  .masklayer {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    // background:rgba(0,0,0,0.5);
    z-index: 110;
    display: flex;
    align-items: center;
    justify-content: center;

    .masks {
      height: 100%;
      width: 100%;
      background: rgba(0, 0, 0, 0.5);
      z-index: 110;
      position: fixed;
      top: 0;
      left: 0;
    }

    .popups {
      width: 500rpx;
      height: 500rpx;
      background: #ffffff;
      border-radius: 10px;
      z-index: 111;
      padding: 40rpx;
      font-family: PingFangSC-Medium, PingFang SC;
      display: flex;
      flex-direction: column;
      justify-content: space-between;

      .titles {
        font-size: 20px;
        font-weight: 600;
        color: $mainText;
        line-height: 30px;
        text-align: center;
      }

      .inp_li {
        display: flex;
        justify-content: center;

        image {
          width: 400rpx !important;
          height: 400rpx !important;
        }
      }
    }
  }
}

.tl-show {
  overflow: hidden;
  position: fixed;
  height: 100%;
  width: 100%;
}
</style>
